﻿using System;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using Blackbird.Common.Utility;
using Blackbird.Core.Editable;
using Blackbird.Core.Editable.Frames;
using Blackbird.Core.Editable.Sprites;
using Blackbird.Dev.Console.Properties;

namespace Blackbird.Dev.Console
{
    internal class Program
    {
        [STAThread]
        private static void Main(string[] args)
        {
            System.Console.WriteLine(Resources.NewModuleMessage);
            System.Console.ReadLine();

            var module = new EditableModule
                             {
                                 Name = "This Module"
                             };

            var sprite = new EditableMultisprite
                             {
                                 Name = "This Sprite"
                             };

            var frameset = new EditableFrameset
                               {
                                   Name = "This Frameset",
                                   Loop = true,
                                   Fps = 30
                               };

            var frame = new EditableFrame
                            {
                                Name = "Frame 001"
                            };

            var img = new BitmapImage(new Uri("c:\\test.png"));
            frame.BitmapSource = img;

            frameset.Add(frame);
            var framesetList = new EditableFramesetList {frameset};
            sprite.Add(framesetList);
            module.SpritePack.Add(sprite);

            SerializationUtility.SaveToFile("c:\\test.mdl", module);

            var module1 = SerializationUtility.CreateFromFile<EditableModule>("c:\\test.mdl");
            var img1 = new Image {Source = module1.SpritePack[0][0][0][0].BitmapSource};

            System.Console.WriteLine(img1.Visibility.ToString());
            System.Console.WriteLine(Resources.PausedExecutionMessage);
            System.Console.ReadLine();
        }
    }
}